home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / ELLIPSE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.1 KB  |  44 lines

  1.                                             /* ellipse.c */
  2.                                  /* Entered by A. Wayner */
  3.  
  4.                                             /* Draw an egg-shaped curve using ellipse */
  5.                                             /* and arc */
  6.  
  7. # include <graphics.h>
  8. main()
  9. {
  10.     int graphdriver = DETECT;
  11.     int graphmode, xc, yc, yradius = 65, xradius = 50, errorcode;
  12.  
  13.                                             /* Detect adapter type and    */
  14.                                             /* initialize graphics system */
  15.       initgraph( &graphdriver, &graphmode, "\\turboc");
  16.     errorcode = graphresult();
  17.     if( errorcode != grOk )
  18.     {
  19.         printf("Graphics error : %s\n",
  20.             grapherrormsg( errorcode ));
  21.         exit( 1 );
  22.     }
  23.  
  24.     xc = getmaxx()/2;
  25.     yc = getmaxy()/2;
  26.  
  27.                                             /* Draw half an ellipse followed */
  28.                                             /* by a semicircle   */
  29.     ellipse( xc, yc, 0, 180, xradius, yradius );
  30.     arc    ( xc, yc, 180, 360, xradius );
  31.  
  32.                                             /* Explain what we've done */
  33.     settextjustify( CENTER_TEXT, CENTER_TEXT );
  34.     settextstyle  ( SANS_SERIF_FONT, HORIZ_DIR, 1 );
  35.  
  36.     outtextxy( xc, 50, "An egg using arc, ellipse");
  37.     outtextxy( xc, 2*yc-50,"Press any key to exit : ");
  38.  
  39.     getch();                                /* Wait until a key is pressed */
  40.     closegraph();                        /* Exit graphics library */
  41.  
  42. }
  43.  
  44.